<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="org.limp.mine.DateTrimmer"%>
<%@ page import="org.limp.mine.StringTool"%>
<%@ page import="jt.classic.system.wordbook.XWordbook" %>
<%@ page import="jt.classic.system.ISystem" %>
<%@ page import="jt.classic.system.user.IUser" %>
<%@ page import="jt.classic.app.info.AInfo" %>
<%@ page import="jt.classic.app.info.AInfoIssue" %>
<%@ page import="java.util.List" %>
<%
   String context = jt.classic.system.ISystem.getContextPath();
   
   IUser user = ISystem.getSessionUser(request);
   
   AInfo info = (AInfo)request.getAttribute("info");
   
   AInfoIssue issue = info.issue();
   
   List list = (List)request.getAttribute("list");
   
   String listtype = (String)request.getAttribute("listtype");
   
   List annexs = (List)info.iannexs();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>信息发布</title>
</head>
<jsp:include page="../head.jsp"></jsp:include>
<script type="text/javascript" src="<%=context%>/app/info/js/myjs.js"></script>
<link rel="stylesheet" type="text/css" href="<%=context%>/app/info/css/directree.css" />
<script type="text/javascript" src="<%=context%>/app/info/js/myjs.js"></script>
<script type="text/javascript" src="<%=context%>/app/info/js/lanmuselect.js"></script>
<link rel="stylesheet" type="text/css" href="<%=context%>/system/group/css/groupmanage.css" />
<script type="text/javascript" src="<%=context%>/system/group/js/groupselect.js"></script>
<script>
   function handleSelect1(){
      <%if(info.idirectory() != null){%>setLanmuPath('<%=info.idirectory().iextpath()%>');<%}%>
      selectlanmu('idid', 'idname');
   }
   
   function handleSelect2(){
      selectGroupOnly('isareaid', 'isareaname');
   }
   
   function responseResult(ids,names,types){
      if(sel == "lanmu"){
         document.form1.idid.value = ids.substring(1);
         document.form1.idname.value = names;
      }else if(sel == "fanwei"){
         document.form1.isareaid.value = ids.replace(/g/g,"");
         document.form1.isareaname.value = names;
      }
      
      closeDialog();
   }
   
   function handleSumbit(){
       if(isblank(document.form1.iftitle)){
          alert("请填写标题");
       }else if(confirm("确定提交")){
          var it = document.form1.itid;
          if(it){
             createHidden("itname",it.options[it.selectedIndex].text);
          }
          
          if(!isblank(document.form1.isareaid)){
             var ids = document.form1.isareaid.value.split(",");
             var names = document.form1.isareaname.value.split(",");
             var countIssue = "";
             if(ids != ""){
	             for(var i=0;i<ids.length;i++){
	                 createHidden("isotype_" + i,"info");
	                 createHidden("isareaid_" + i,ids[i]);
	                 createHidden("isareaname_" + i,names[i]);
	                 createHidden("isastime_" + i,"");
	                 createHidden("isaestime_" + i,"");
	                 createHidden("ifid_" + i,"<%=info.id()%>");
	                 if(i == ids.length - 1){
	                    countIssue += i;
	                 }else{
	                    countIssue += i + ",";
	                 }
	             }
             }else{
                 countIssue = "0";
                 createHidden("isotype_0","info");
	             createHidden("isareaid_0","0");
	             createHidden("isareaname_0","");
	             createHidden("isastime_0","");
	             createHidden("isaestime_0","");
             }
             
             createHidden("countIssue",countIssue);
          }

            Ext.MessageBox.wait('提交保存过程中...');   
		    Ext.Ajax.request({       
		        //请求地址       
		       url: context + "/app/info.do?method=updateinfo",       
		       //提交参数组       
		       fileUpload: true,   
		       form: 'form1',   
		       scope: 'form1',     
		       //成功时回调       
		       success: function(response, options) {       
		           //获取响应的json字符串        
		           Ext.MessageBox.hide();
		           
		           var json = response.responseText;    
	                  var o = Ext.util.JSON.decode(json);
		           
		           if (o.success) {
	                       
	                      /*
	                   Ext.Msg.alert('提示', '提交保存成功！');   
	                      window.document.form1.reset();
	                      getFrameDocument('FCKeditor1___Frame').FCKUndo.SaveUndoStep();
					   getFrameDocument('FCKeditor1___Frame').FCK.SetHTML('');
					   getFrameDocument('FCKeditor1___Frame').FCKUndo.Typing = true;
					   */
					   alert("提交保存成功！");
					   handleRefresh();
	                  }else{
		               Ext.Msg.alert('提示', '提交保存失败！'); 
		           }                
		       }      
		     });
       }
   }
   
   function deleteAnnex(id,name){
		  if(confirm("确定删除附件 '" + name + "'")){
		      var url = context + "/system/annex.do?method=delete&id=" + id;
		      var res = sendRequest(url);
		      if(res == 1){
		         document.getElementById("tr_" + id).parentNode.removeChild(document.getElementById("tr_" + id));
		         document.getElementById("allfree").style.display = "block";
		      }
		  }
    }
    
   function viewAnnex(id){
    document.getElementById("helper").src = context + "/system/annex.do?method=view&id=" + id;
  }
</script>
<body>
<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>
<form id="form1" name="form1" method="post" enctype="multipart/form-data" action="">
<input type="hidden" name="ifid" value="<%=info.id()%>">
<input type="hidden" name="ifstatus" value="0">
<div style="margin-top:15px;margin-left:15px;">
<input type="button" value="保存" onclick="javascript:handleSumbit();">
<input type="reset" value="重新编辑">
<input type="reset" value="返回" onclick="javascript:window.history.back(-1);">
</div>
<fieldset id="lanmu" style="margin-left:15px;width:90%;">
<legend>信息发布 - 信息编辑</legend>
<label for="iftitle">标题</label>
<input type="text" id="iftitle" name="iftitle" class="box3" style="width:550px;" value="<%=info.ititle()%>"/>&nbsp;<img src="<%=context %>/app/info/images/theme.png" style="cursor:hand;" onclick="javascript:showPanel('');" title="设计"/>
    <input type="hidden" name="uniqueid" value="<%=info.id()%>">
    <input type="hidden" id="iffont" name="iffont" value="<%=info.ititlefont()%>">
    <input type="hidden" id="ifcolor" name="ifcolor" value="<%=info.ititlecolor()%>">
    <input type="hidden" id="ifsize" name="ifsize" value="<%=info.ititlesize()%>">
<br/>
<label for="ifprovide">信息提供人</label>
<input type="text" style="width:550px;" id="ifprovide" name="ifprovide" value="<%=info.getResource().get("IF_PROVIDE")%>"/>
<br/>
  <%if(listtype.indexOf("type") > -1){%>
  <label for="itid">类别</label><select id="itid" name="itid">
	   <%
	     if(list != null && !list.isEmpty()){
	        for(int i=0;i<list.size();i++){
	            XWordbook wb = (XWordbook)list.get(i);
	   %>
	   <option value="<%=wb.getID()%>" <%=(info.itypeid().equals(wb.getID()))?"selected":""%>><%=wb.getName()%></option>
	   <%
	        }
	     }
	   %>
	</select>
	<br/>
  <%}%>
  <%if(listtype.indexOf("directory") > -1){%>
  <label for="idname">所属栏目</label>
  <input type="text" id="idname" name="idname" style="width:550px;" readonly value="<%=info.idirectory()!=null?info.idirectory().iextpathtext():""%>"/>&nbsp;<img src="<%=context %>/app/info/images/theme.png" style="cursor:hand;" onclick="javascript:handleSelect1();" title="选择"/>
  <input type="hidden" id="idid"  name="idid" value="<%=info.idirectory()!=null?info.idirectory().id():""%>"/>
  <br/>
  <%}%>
  <label for="ititle">发布范围</label>
  <input style="width:550px;" readonly type="text" id="isareaname" name="isareaname" value="<%=issue.iareaname()%>"/>&nbsp;<img src="<%=context %>/app/info/images/theme.png" style="cursor:hand;" onclick="javascript:handleSelect2();" title="选择"/>
  <input type="hidden" id="isareaid" name="isareaid" value="<%=issue.iareaid()%>"/>
    <%
      if(issue.iareaid() != null && !issue.iareaid().equals("")){
      String[] ids = issue.iareaid().split(",");
      for(int i=0;i<ids.length;i++){
    %>      
    <input type="hidden" id="g<%=ids[i]%>" name="g<%=ids[i]%>" value="g<%=ids[i]%>">
    <%
      }
      }
    %>
  <br/>
  <label>发布人</label>
  <b><%=info.iuser().iname()%></b>
  <br/>
  <label>所属部门</label><b><%=(info.iuser().igroup() != null)?info.iuser().igroup().iflumelabel(null):""%></b>
  <br/>
  <label
	for="iftop">置顶顺序</label> <input type="text" id="iftop" name="iftop"
	style="width:550px;" value="<%=info.itop() %>"/><br />					
<label for="ifreceipt0">开放评论</label>  <input id="ifreceipt0"
	name="ifreceipt" <%=(info.ireceipt() ? "checked" : "") %> type="radio" value="1" /> 是 <input id="ifreceipt1"
	name="ifreceipt" <%=(!info.ireceipt() ? "checked" : "") %> type="radio" value="0" /> 否 <br />
  <!--
  <tr>
    <td>生效时间</td>
    <td><input type="text" readonly onclick="javascript:HS_setDate(this)" name="isastime" /> 至 <input type="text" name="isaetime" readonly onclick="javascript:HS_setDate(this)"/></td>
  </tr>
  -->
  <%if(listtype.equals("type")){%>
  <label for="ifreceipt">是否回执</label>
      是
      <input id="ifreceipt" name="ifreceipt" type="radio" value="1" <%=info.ireceipt()?"checked":""%>/>
      否
      <input name="ifreceipt" type="radio" value="0" <%=!info.ireceipt()?"checked":""%>/><br/>
  <%}else{%>
  <input name="ifreceipt" type="hidden" value="0" />
  <%}%>
  <label for="allfree">添加附件</label>	
    <%if(annexs != null && !annexs.isEmpty()){
	    for(int i=0;i<annexs.size();i++){
	        String[] temp = (String[])annexs.get(i);
	 %>
  <a href="javascript:void(0);" onclick="javascript:viewAnnex('<%=temp[0]%>');"><%=temp[1]%></a>
  <a href="javascript:void(0);" onclick="javascript:deleteAnnex('<%=temp[0]%>','<%=temp[1]%>');$('allfree').style.display='block';">删除</a>
  <input type="file" id="allfree" style="width:550px;display:none;" name="ALLFREE" value="">
     <%      
        }    
      }else{
     %>
 <input type="file" id="allfree" style="width:550px;" name="ALLFREE" value="">
 <%} %>
    <br/>
 <label>内容概要</label> <textarea style="width:550px;"
	id="ifsummary" name="ifsummary"><%=info.isummary()%></textarea> <br/>   
 <label>正文内容</label>
	<input type="hidden" name="ifcontent" value="<%=((String)info.icontent()).replaceAll("\"", "&quot;")%>"> <iframe
		id="FCKeditor1___Frame"
		src="<%=context%>/resources/fckeditor/editor/fckeditor.html?InstanceName=ifcontent&Toolbar=xfile&uniqueid=<%=info.id() %>"
		width="100%" height="400" frameborder="0" scrolling="no"></iframe>
	<br/>
</fieldset>
</form>
<iframe id="helper" name="helper" style="display:none;"></iframe>
</body>
</html>